{extend name="public:layout" /}
{block name="title"}订单详情{/block}
{block name="head"}
<style>
    .footer-page {
        height: 44px;
        line-height: 44px;
        bottom: 0px;
        left: 0;
        background: #fff;
        border-top: #e8eced solid 1px;
        position: fixed;
        width: 100%;
        margin: 0 -5px;
        text-align:center;
        z-index:9999;
    }
</style>
{/block}
{block name="body"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <li><i class="fa fa-hand-o-right"></i> <a href="{:url('index')}"> 订单列表</a></li>
                <li class="active">订单详情</li>
            </ol>
        </div>
        <div class="ibox-content">
            {include file="shop_order/detail" /}
        </div>
    </div>
</div>
<div style="height:40px;"></div>
<div class="footer-page">
    {if condition="($orderInfo['pay_status'] == 0)"}
    <button type="button" class="btn btn-info" onclick="doPay(this);" data-url="{:url('orderPay',['order_id'=>$vo['order_id']])}">支付订单</button>
    {/if}
    {if condition="($orderInfo['order_status'] == 0)"}
    <button type="button" class="btn btn-info" onclick="confirmOrder(this);" data-orderid="{$vo.order_id}" data-url="{:url('orderConfirm')}">确认订单</button>
    {/if}
    {if condition="($orderInfo['order_status'] == 1) && ($orderInfo['shipping_status']==0) "}
    <button type="button" class="btn btn-info" onclick="delivery(this);" data-url="{:url('orderDelivery',['order_id'=>$vo['order_id']])}">订单发货</button>
    {/if}
    {if condition="($orderInfo['order_status'] == 1) && ($orderInfo['shipping_status']==1) "}
    <button type="button" class="btn btn-info" onclick="finnshed(this)" data-url="{:url('orderFinnshed',['order_id'=>$vo['order_id']])}">确认收货</button>
    {/if}
    {if condition="($orderInfo['pay_status'] == 1) && $orderInfo['pay_price']>$orderInfo['refund_amount']"}

    <button type="button" class="btn btn-info" onclick="orderReturn(this);" data-url="{:url('orderReturn',['order_id'=>$vo['order_id']])}">订单退款</button>
    {/if}
    {if condition="($orderInfo['shipping_status']==0)"}
    <button type="button" class="btn btn-danger" onclick="closeOrder(this)" data-url="{:url('orderClose',['order_id'=>$vo['order_id']])}">作废订单</button>
    {/if}
    {if condition="($orderInfo['order_status'] == 0) && ($orderInfo['shipping_status']==0) "}
    <a href="javascript:;" onclick="doAction(this);" class="btn btn-danger"
       data-msg="只有未付款并未确认得订单可删除<br/>确认删除吗？" data-url="{:url('orderDel')}" data-params="order_id={$vo.order_id}">删除订单</a>
    {/if}
    <a href="{:url('index')}" class="btn btn-info">返回</a>
</div>
{/block}
{block name="script"}
<script>
    //订单支付
    function doPay(obj) {
        var url = $(obj).data('url');
        In('layer',function () {
            layer.open({
                title: '订单支付',
                type: 2,
                area: ['800px', '480px'],
                content: url
            });
        })
    }
    //关闭订单
    function closeOrder(obj) {
        In('layer',function () {
            layer.confirm('确认作废该订单吗？', {icon: 3, title:'提示'}, function(index){
                var url = $(obj).data('url');
                getAjax(url,'',function (res) {
                    layer.close(index);
                    if(res.code==1){
                        rePage();
                    }else{
                        layer.alert(res.msg);
                    }
                })
            });
        })
    }
    //订单退款
    function orderReturn(obj) {
        var url = $(obj).data('url');
        In('layer',function () {
            layer.open({
                title: '订单退款',
                type: 2,
                area: ['800px', '480px'],
                content: url
            });
        })
    }
    //确认收货
    function finnshed(obj) {
        In('layer',function () {
            layer.confirm('确认收货吗？', {icon: 3, title: '提示'}, function (index) {
                var url = $(obj).data('url');
                getAjax(url, '', function (res) {
                    if (res.code == 1) {
                        rePage();
                    } else {
                        layer.alert(res.msg);
                    }
                })
                layer.close(index);
            });
        })
    }
    //订单发货
    function delivery(obj) {
        var url = $(obj).data('url');
        In('layer',function () {
            layer.open({
                title: '订单发货',
                type: 2,
                area: ['800px', '480px'],
                content: url
            });
        })
    }
    //订单确认
    function confirmOrder(obj){
        In('layer',function(){
            layer.confirm('确认操作吗？', {icon: 3, title:'提示'}, function(index){
                var url = $(obj).data('url');
                var orderId = $(obj).data('orderid');
                getAjax(url,{order_id:orderId},function (res) {
                    if(res.code==1){
                        rePage();
                    }else{
                        layer.alert(res.msg);
                    }
                })
                layer.close(index);
            });
        })
    }
</script>
{/block}